<template>
  <div class="player">
    <div class="song-control">
      <h1>Mv播放</h1>
      <video :src="songUrl" controls autoplay></video>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      songUrl: ["http://118.112.10.153/mv.music.tc.qq.com/AkTqrG2_lHPMpt74J-ZC-0OmzLX-n9br4_XGIEI5JVxw/D3070EB875C019D03091D634952D5467B60B9F3BFD047C284A13B89F5CB052DCF554DC2E457E21D44BEF78E831E2A06FZZqqmusic_default/1049_M0135300000HdtXk2avwNV1001676254.f9814.mp4?fname=1049_M0135300000HdtXk2avwNV1001676254.f9814.mp4",
      ],
      singer: {},
      picUrl: "",
    };
  },
  created() {
    this.getData();
    this.getStoreSinger();
    this.getDatas;
  },
  methods: {
    getData() {
      axios
        .get("http://171.220.242.237:3002/mv/url", {
          params: {
            id: this.$route.params.id,
          },
        })
        .then((res) => {
          console.log(res.data.data);
          this.songUrl = res.data.data[this.$route.params.id];
        })
        .catch((err) => {
          console.error(err);
        });
    },
    getStoreSinger() {
      console.log(this.$store.state.singer);
      console.log(Object.keys(this.$store.state.singer).length);
      // this.singer = this.$store.state.getters.singer;
      //   this.singer = sessionStorage.getItem("singer");
      if (Object.keys(this.$store.state.singer).length) {
        this.singer = this.$store.state.singer;
        sessionStorage.setItem(
          "singer",
          JSON.stringify(this.$store.state.singer)
        );
      } else {
        this.singer = JSON.parse(sessionStorage.getItem("singer"));
      }
    },
     getDatas() {
      axios
        .get("http://171.220.242.237:3002/songlist", {
          params: {
            id: this.$route.params.id,
          },
        })
        .then((res) => {
          console.log(res.data.data.songlist);
          this.songList = res.data.data.songlist;
          this.picUrl = res.data.data.logo;
          this.firstItem = this.songList[0];
        })
        .catch((err) => {
          console.error(err);
        });
    },
  },
};
</script>
<style scoped>
</style>